<?php
class TestOfResponse extends UnitTestCase {

    function testNewEmptyResponse() 
    {
        $response = new response();

        $this->assertEqual($response->action,'ok');
        $this->assertEqual($response->vars,array());
        $this->assertNull($response->view);
        $this->assertNull($response->app);
    }

    function testNewResponse() 
    {
        $response = new response('notfound');

        $response->assign('var1',23);
        $response->assign('var2','var2');
        $response->assign('var3',array(1,2,3));

        $this->assertEqual($response->action,'notfound');
        $this->assertEqual($response->vars[var1],23);
        $this->assertEqual($response->vars[var2],'var2');
        $this->assertEqual($response->vars[var3],array(1,2,3));

        $response->view('template','app');
        $this->assertEqual($response->view,'template');
        $this->assertEqual($response->app,'app');
    }

    function testUnknownAction()
    {
        $response = new response('not_existing_action');

        $this->expectException('Exception','sbook/response: unknown response action!');
        $response->render();
    }

}
?>
